<!-- 多文件上传 -->
<template>
  <div>
    <singleUpload v-model="imgs" />
    <button @click="handleClick">
      ces
    </button>
  </div>
</template>

<script>
import singleUpload from '../modules/common/upload/singleUpload.vue';

export default {

  data() {
    return {
      imgs: 'http://192.168.101.131:9000/test/1741101102266.png',
      uploadUrl: 'http://localhost:88/api/oss/upload',
      maxCount: 20,
      dialogImageUrl: '',
      dialogVisible: false
    };
  },
  components: {
    singleUpload
  },
  methods: {
    // 上传成功回调
    // handle_success(res) {
    //   console.log(res)
    //   this.$message.success('图片上传成功', res)
    //   // 上传成功后，将图片地址赋值给dataForm.mainImage
    // },

    handle_success(res, file) {
      this.fileList.push({
        name: res.data,
        // url: this.dataObj.host + "/" + this.dataObj.dir + "/" + file.name； 替换${filename}为真正的文件名
        url: res.data
      });
      this.emitInput(this.fileList);
    },
    handleExceed(files, fileList) {
      this.$message({
        message: "最多只能上传" + this.maxCount + "张图片",
        type: "warning",
        duration: 1000
      });
    },

    handleClick() {
      console.log('this.imgs', this.imgs);

    },

    handleRemove(file, fileList) {
      console.log(file, fileList);
      this.emitInput(fileList);
    },
    handlePictureCardPreview(file) {
      this.dialogImageUrl = file.url;
      this.dialogVisible = true;
    },
    emitInput(fileList) {
      let value = [];
      for (let i = 0; i < fileList.length; i++) {
        value.push(fileList[i].url);
      }
      this.$emit("input", value);
    },

  },
  computed: {
    fileList() {
      let fileList = [];
      for (let i = 0; i < this.value.length; i++) {
        fileList.push({ url: this.value[i] });
      }

      return fileList;
    }
  },
}
</script>
